package com.mxpio.erp.common.oa.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "MB_ERP_OA_POST_TRANSFER")
@Schema(description = "岗位调动表")
public class PostTransferApply extends BaseEntity {


    @Id
    @Column(name = "BIZ_NO_", updatable = false)
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "工单编号")
    private String bizNo;

    @Column(name = "EMPLOYEE_NAME_")
    @Schema(description = "员工工号")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String employeeId;

    @Column(name = "SOURCE_DEPT_CODE_")
    @Schema(description = "原部门编号")
    @Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String sourceDeptCode;

    @Column(name = "TRANSFER_DEPT_CODE_")
    @Schema(description = "申请转入部门编号")
    @Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String transferDeptCode;

    @Column(name = "SOURCE_POST_")
    @Schema(description = "员工原岗位")
    private String sourcePost;

    @Column(name = "TRANSFER_POST_")
    @Schema(description = "申请岗位")
    private String transferPost;


    @Column(name = "HAS_POST_CERTIFICATE_")
    @Schema(description = "新岗位有无职能证书")
    @Dict(dicCode = "ERP_COMMON_YESNO")//0=无,1=有
    private String hasPostCertificate;

    @Column(name = "FILE_NO_")
    @Schema(description = "附件")
    private String fileNos;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "转岗生效时间")
    @Column(name = "TRANSFER_EFFECTIVE_TIME")
    private Date transferEffectiveTime;


    @Column(name = "TRANSFER_REASON_")
    @Schema(description = "调岗原因")
    private String transferReason;
    /**
     * 审批状态
     */
    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审批状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    /**
     * 审批实例ID
     */
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")
    private String processInstanceId;
}
